﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using DevExpress.XtraEditors.Repository;

namespace WmsApp.StaticData
{
    public class GoodsCodeTypeObserver : BaseGoodsCodeTypeObserver
    {
        /// <summary>
        /// 
        /// </summary>
        /// <param name="name"></param>
        /// <param name="goodsCodeTypeSubject"></param>
        /// <param name="goodsCodeTypeLookUpEdit">此对象必须包含DataSource可写属性</param>
        /// <param name="form"></param>
        public GoodsCodeTypeObserver(string name,
            IGoodsCodeTypeSubject goodsCodeTypeSubject,
             Object goodsCodeTypeLookUpEdit,Form form )
            :base(name,goodsCodeTypeSubject,goodsCodeTypeLookUpEdit,form)
        {
        
        }

        public override void UpdateData()
        {
            if (this.GoodsCodeTypeLookUpEdit != null)
            {
                if (GoodsCodeTypeLookUpEdit is LookUpEditBase)
                {
                    ((LookUpEdit)this.GoodsCodeTypeLookUpEdit).Properties.DataSource = StaticObjects.GetGoodsCodeTypes();
                }
                else if (GoodsCodeTypeLookUpEdit is RepositoryItemGridLookUpEdit)
                {
                    ((RepositoryItemGridLookUpEdit)this.GoodsCodeTypeLookUpEdit).DataSource = StaticObjects.GetGoodsCodeTypes();
                }
            }
        }
    }
}
